package com.team11.server.controller.student;

import com.team11.server.pojo.dto.RespBean;
import com.team11.server.pojo.dto.RespPageBean;
import com.team11.server.pojo.dto.vo.AddLeave;
import com.team11.server.pojo.dto.vo.Leave;
import com.team11.server.service.ICInformationService;
import com.team11.server.service.ILInformationService;
import com.team11.server.service.ISInformationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.time.LocalDate;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author mahongtao
 * @since 2021-06-17
 */
@CrossOrigin
@RestController
@RequestMapping("/student")
@Api(tags = "学生接口")
public class StudentLInformationController {

    @Resource
    private ILInformationService informationService;

    @ApiOperation(value = "请假管理：获取该学生请假管理的记录（分页）")
    @PostMapping("/getStudentLInformation")
    public RespPageBean getStudentLInformation(@RequestParam(defaultValue = "1") Integer currentPage,
                                               @RequestParam(defaultValue = "10") Integer size,
                                               @RequestParam("sNumber") Integer sNumber,
                                               Leave leave) {
        return informationService.getStudentLInformation(currentPage, size, sNumber, leave);

    }

//    @ApiOperation(value = "请假管理：进入编辑页面")
//    @PostMapping("/openLeave")
//    public List openLeave(@RequestParam("sid") Integer sid, Integer lId) {
//        return informationService.openLeave(sid,lId);
//
//    }

    @ApiOperation(value = "请假管理：请假详情（编辑）页面")
    @PostMapping("/openLeave")
    public List openLeave(@RequestParam("lId") Integer lId) {
        return informationService.openLeave(lId);

    }

    @ApiOperation(value = "请假管理：新增请假")
    @PostMapping("/addLeave")
    public RespBean addLeave(@RequestParam("sid") Integer sid,
                             AddLeave addLeave,
                             MultipartFile[] files,
                             HttpServletRequest request) {
        return informationService.addLeave(sid, addLeave, files, request);

    }

    @ApiOperation(value = "请假管理：编辑请假")
    @PostMapping("/updateLeave")
    public RespBean updateLeave(@RequestParam("lId") Integer lId,
                                AddLeave addLeave, MultipartFile[] files,
                                HttpServletRequest request) {
        return informationService.updateLeave(lId, addLeave, files, request);
    }

}

